package com.bsj.travel.enums;

import com.bsj.travel.util.StringUtils;

/**
 * @author yinhao
 * @version 1.0
 * @description MQTT事件枚举
 * @date 2023/11/13
 */
public enum MqttEventEnum {

    //OTA升级[基础通信类]
    OTA("OTA"),
    //时钟同步[基础通信类]
    NTP("NTP"),
    //设备影子[基础通信类]
    SHADOW("SHADOW"),
    //属性上报[物模型]
    ATTRIBUTE("ATTRIBUTE"),
    //属性设置[物模型]
    SETATTR("SETATTR"),
    //事件上报[物模型]
    SETEVENT("SETEVENT"),
    //自定义主题
    CUSTOMIZE("CUSTOMIZE"),
    ;

    private final String name;

    MqttEventEnum(String name) {
        this.name = name;
    }

    public static MqttEventEnum getMqttEventEnum(String name) {
        if (StringUtils.isEmpty(name)) {
            return null;
        }
        switch (name.toUpperCase()) {
            case "OTA":
                return OTA;
            case "NTP":
                return NTP;
            case "SHADOW":
                return SHADOW;
            case "ATTRIBUTE":
                return ATTRIBUTE;
            case "SETATTR":
                return SETATTR;
            case "SETEVENT":
                return SETEVENT;
            case "CUSTOMIZE":
                return CUSTOMIZE;
            default:
                return null;
        }
    }

}
